package com.xy.p2p.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.p2p.dao.TnoticeinforDao;
import com.xy.p2p.model.Tnoticeinfor;
import com.xy.p2p.service.TnoticeinforService;

@Service
@Transactional
public class TnoticeinforServiceImpl extends BaseServiceImpl<Tnoticeinfor> implements
		TnoticeinforService {
	private TnoticeinforDao tnoticeinforDao;

	public TnoticeinforServiceImpl(TnoticeinforDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.tnoticeinforDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return tnoticeinforDao.checkExist("Tnoticeinfor", paraName, paraValue);
	}

	@Override
	public List<Tnoticeinfor> getTnoticeinfor(Map<String, Object> map) {
		return tnoticeinforDao.getTnoticeinfor(map);
	}
	@Override
	public Pagination getTnoticeinforByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return tnoticeinforDao.getTnoticeinforByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Tnoticeinfor save(Tnoticeinfor tnoticeinfor) {
//		tnoticeinfor.setModtime(new Date());
		if(tnoticeinfor.getNiid()==null){
			//新增
			tnoticeinfor.setNidate(new Date());
        	return super.save(tnoticeinfor);
		}else{
			//更新
			Tnoticeinfor tnoticeinfor1=tnoticeinforDao.get(tnoticeinfor.getNiid());
			try {
				BeanUtil.copyNotNullProperties(tnoticeinfor1, tnoticeinfor);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(tnoticeinfor1);
		}
	}
}